<?php
namespace  Admin\Controller;
use Think\Controller;
class IndexController extends CommonController {
    public function index(){

        $admin_db      = D('Admin');
        $menu_db       = D('Menu');

        $userid = session('userid');
        $userInfo = $admin_db->getUserInfo($userid);    //获取用户基本信息
        $menuList = $menu_db->getMenu();                //头部菜单列表

        $this->assign('userInfo', $userInfo);
        $this->assign('menuList', $menuList);
        $this->display('index');
    }
    public function test(){
        if(IS_POST){

        }
        else{
            $this->display();
        }
    }
    /**
     * 左侧菜单
     */
    public function public_menuLeft($menuid = 0) {
        $menu_db = D('Menu');
        $datas = array();
        $list = $menu_db->getMenu($menuid);
        foreach ($list as $k=>$v){
            $datas[$k]['name'] = $v['name'];
            $son_datas = $menu_db->getMenu($v['id']);
            foreach ($son_datas as $k2=>$v2){
                $datas[$k]['son'][$k2]['text'] = $v2['name'];
                $datas[$k]['son'][$k2]['id']   = $v2['id'];
                $datas[$k]['son'][$k2]['url'] = U($v2['c'].'/'.$v2['a'].'?menuid='.$v2['id'].'&'.$v2['data']);
            }
        }
        $this->ajaxReturn($datas);
    }
}